package com.siyougame.business.dal.mysql.template;

import java.util.*;

import com.siyougame.business.controller.app.vo.AppTemplatePageReqVO;
import com.siyougame.business.dal.dataobject.templateItem.TemplateItemDO;
import com.siyougame.business.enums.TemplateStatusEnum;
import com.siyougame.common.pojo.PageResult;
import com.siyougame.mybatis.mybatis.core.query.LambdaQueryWrapperX;
import com.siyougame.mybatis.mybatis.core.mapper.BaseMapperX;
import com.siyougame.business.dal.dataobject.template.TemplateDO;
import org.apache.ibatis.annotations.Mapper;
import com.siyougame.business.controller.admin.template.vo.*;

/**
 * 模板 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface TemplateMapper extends BaseMapperX<TemplateDO> {

    default PageResult<TemplateDO> selectPage(TemplatePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TemplateDO>()
                .likeIfPresent(TemplateDO::getName, reqVO.getName())
                .eq(TemplateDO::getStatus, TemplateStatusEnum.NORMAL.getCode())
                .eq(TemplateDO::getDepartmentId, reqVO.getDepartmentId())
                .eqIfPresent(TemplateDO::getRemark, reqVO.getRemark())
                .eqIfPresent(TemplateDO::getSortRank, reqVO.getSortRank())
                .eqIfPresent(TemplateDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(TemplateDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(TemplateDO::getId));
    }
    default PageResult<TemplateDO> selectPage(AppTemplatePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TemplateDO>()
                .likeIfPresent(TemplateDO::getName, reqVO.getName())
                .eq(TemplateDO::getStatus, TemplateStatusEnum.NORMAL.getCode())
                .eq(TemplateDO::getDepartmentId, reqVO.getDepartmentId())
                .orderByDesc(TemplateDO::getId));
    }
    //
    //default List<TemplateDO> selectList(TemplateExportReqVO reqVO) {
    //    return selectList(new LambdaQueryWrapperX<TemplateDO>()
    //            .likeIfPresent(TemplateDO::getName, reqVO.getName())
    //            .eq(TemplateDO::getStatus, TemplateStatusEnum.NORMAL.getCode())
    //            .eqIfPresent(TemplateDO::getRemark, reqVO.getRemark())
    //            .eqIfPresent(TemplateDO::getSortRank, reqVO.getSortRank())
    //            .eqIfPresent(TemplateDO::getDescription, reqVO.getDescription())
    //            .betweenIfPresent(TemplateDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
    //            .orderByDesc(TemplateDO::getId));
    //}

}